home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / VFD17.ZIP / DMPEG.DOC < prev    next >
Text File  |  1993-05-24  |  13KB  |  354 lines

  1.  
  2.                               DMPEG V1.1
  3.  
  4.                        Public Domain MPEG decoder
  5.  
  6.                            by Stefan Eckart
  7.  
  8.                                June 1993
  9.  
  10. 1. Features
  11. ===========
  12.  
  13. DMPEG is another MPEG decoder/player for the PC:
  14.  
  15.  
  16.  - decodes (nearly) the full MPEG video standard
  17.    (I,P,B frames, frame size up to at least 352x288)
  18.  
  19.  - can save decoded sequence in 8 or 24bit raw file for
  20.    fast off-line display (two pass mode)
  21.  
  22.  - optional on-screen display during decoding
  23.  
  24.  - several dithering options for 8 bit displays:
  25.      ordered dither, Floyd-Steinberg, grayscale
  26.  
  27.  - selectable color-space
  28.  
  29.  - runs under DOS, 640KB RAM, no MS-Windows or '386 required
  30.  
  31.  - compact (small code / small data models, 16 bit arithmetic)
  32.  
  33.  - supports VGA, many Super-VGAs (including VESA) and
  34.    some TrueColor SVGAs
  35.  
  36.  
  37. 2. Introduction
  38. ===============
  39.  
  40. DMPEG is a Public Domain decoder for files containing MPEG video
  41. sequences. MPEG is a standardized format for compressed storage of video
  42. (and audio), similar in concept to JPEG for individual images. It,
  43. however, provides higher compression by exploiting the similarity of
  44. consecutive images of a sequence, so called interframe coding. As with
  45. JPEG, the compression factor depends on the source material and the
  46. desired quality of the coded sequence. A compression to less than 5% of
  47. the original material is not uncommon.
  48.  
  49. DMPEG supports the full MPEG video standard, except D-frame sequences.
  50. Decoding is not very fast, therefore a two-pass mode was implemented:
  51. during the first pass the sequence is decoded and stored in an unencoded
  52. file which then can be played at maximum speed during the second pass.
  53. Of course DMPEG also has a one-pass mode where the sequence is displayed
  54. immediately but at lower speed. The speed is about one seventh of that
  55. of the Xing MPEG decoder (see appendix A). The Xing player, however, can
  56. only decode I frame sequences of size 160x120 and needs a '386. I
  57. suggest to use DMEG in addition to Xing's MPEG.EXE 320x200 DOS player.
  58. The latter is appropriate for real-time display of '160x120, I-frame
  59. only' Xing files, DMPEG is more suitable for larger size 'real' MPEGs
  60. containing I, P and B type, 352x288 sized frames or for faster and
  61. better quality 'off-line' display of the 160x120 MPEGs. Try it on one of
  62. the larger MPEG files (see appendix, my recommendation: flowg.mpg) to
  63. see that MPEG can also be used (and is intended) for storing really
  64. sharp, virtually noise-free sequences.
  65.  
  66. To give an impression of the attainable speeds, here are some figures
  67. measured on a 386DX/33 with 4MB RAM and a Conner 3104 100 MB hard disk.
  68. The decoding time for flowg.mpg (352x240) was about 4 sec per frame, 9
  69. minutes for 150 frames. waterski.mpg (336x208 and higher compression)
  70. required only 2.4 sec per frame. A decoded 150 frame raw data file is
  71. 12 MB long and can be displayed at 5.2 frames/s. 160x120 MPEGs reach
  72. 22 frames/s while the decoding speed is 1.9 sec/frame. The display frame
  73. rate is limited by the transfer speed from hard disk to memory (about
  74. 550 kByte/s on my PC). If you have enough RAM, you can obtain much
  75. higher speed by playing from a large RAM-disk (e.g 23 frames/s for a
  76. 352x240 sequence).
  77.  
  78. This program is Public Domain and I don't take any responsibility
  79. regarding its fitness, usefulness etc. (#include
  80. <your_favourite_disclaimer>). Comments, bug reports, questions to:
  81.  
  82.   Stefan Eckart
  83.   Kagerstr. 4
  84.   D-81669 Muenchen
  85.   Germany
  86.  
  87.   email: stefan@lis.e-technik.tu-muenchen.de
  88.  
  89. Any feedback is welcome.
  90.  
  91.  
  92. 3. Usage
  93. ========
  94.  
  95.   dmpeg [options] input.mpg [output.raw]
  96.  
  97.   dmpeg [options] input.raw
  98.  
  99. input.mpg   any MPEG DIS 11172 compliant non multiplexed compression
  100.             layer video stream (D frame streams unsupported)
  101.  
  102. output.raw  the decoded and dithered 8 or 24bit raw output file;
  103.             if omitted: output to screen only
  104.  
  105. input.raw   previously decoded raw file to be displayed at maximum speed
  106.  
  107. Options:
  108.  
  109.  -q     quiet mode; no text output (except error messages)
  110.  -v     verbosity level; can be increased by repeating this option;
  111.         enables display of decoded information (start codes, frame size,
  112.         quantization scales etc.), can't be combined with the -s option
  113.  
  114.  -dx    dithering options:
  115.  
  116.  -d0    ordered, saturation dominant 4x4 dither (default)
  117.  -d1    Floyd-Steinberg error-diffusion / blue-noise-shaping (2 weights)
  118.  -d2    Floyd-Steinberg error-diffusion / blue-noise-shaping (4 weights)
  119.  -d3    undithered grayscale output
  120.  -d4    24 bit true color output
  121.  
  122.  -p0    use full color range palette
  123.  -p1    use restricted color range palette (default)
  124.  
  125.  -sn    select graphics adapter:
  126.  
  127.  -s0    either standard VGA or Super-VGA in 320x200x256 mode (default)
  128.         (options -d0..3) or a TrueColor VGA with VESA BIOS in
  129.         320x200x16M mode (option -d4)
  130.  -s1    VESA BIOS, either 640x480x256 (-d0..3) or 640x480x16M (-d4)
  131.  -s2    ET4000               \
  132.  -s3    ET3000               |
  133.  -s4    Video 7              |
  134.  -s5    Paradise             | 640x480x256
  135.  -s6    Trident              | (options -d0..3 only)
  136.  -s7    Chips & Technologies |
  137.  -s8    ATI                  |
  138.  -s9    Orchid               |
  139.  -s10   Oaktech              /
  140.  
  141.  -lx   delay (x=0..65535, default 0), used only for offline display
  142.  
  143.  -b    use 8 bit transfer (default: 16 bit) into (S)VGA memory
  144.  
  145.  
  146. Options can be combined. Example:
  147.  
  148.   dmpeg -d2s0 flowg.mpg flowg.raw
  149.  
  150. decodes MPEG file flowg.mpg to raw file flowg.raw using FS4 dithering
  151. and displays it on the screen in 320x200x256 mode.
  152.  
  153.   dmpeg -vvv flowg.mpg flowg.raw
  154.  
  155. as above but using ordered dither and printing much information about
  156. startcodes, headers and parameters.
  157.  
  158. All SVGA drivers use the 640x480x256 display mode and require at least
  159. 512 kB of video memory. If your graphics card is not listed, the best
  160. you can do (besides trying all drivers in the hope that one of them
  161. might work) is to obtain a VESA BIOS extension for your card and use
  162. mode -s1. A collection of such drivers had been posted to
  163. comp.binaries.ibm.pc and is also available at
  164. ftp.rahul.net:/pub/bryanw/pc/vesadrv2.zip (anonymous ftp).
  165.  
  166. All drivers except the standard VGA, ET4000, the VESA driver in
  167. conjunction with the mentioned public domain VESA BIOS extension TSR for
  168. the ET4000 and the TrueColor driver with a Cirrus Logic VGA are
  169. untested. I'm very interested in email feedback which drivers work and
  170. which don't.
  171.  
  172. The -l option controls playback speed. It is implemented as a simple
  173. delay loop without synchronization to a timer or vertical retrace.
  174.  
  175. The -b option is probably superfluous. I don't have much experience in
  176. PC graphics programming and since I saw some example driver routines
  177. using bytewise transfer (rep movsb) instead of wordwise (rep movsw) I
  178. preferred to include this as a fudge factor. You should try it only in
  179. case of problems. Speed is reduced considerably if you activate this
  180. switch (at least for cards with 16 bit bus interface).
  181.  
  182. Decoding can be terminated by pressing any key.
  183.  
  184. Offline display can be controlled with the following keys:
  185.  
  186.   any key except
  187.   space, return
  188.   or escape       halt display at current frame and step one frame
  189.                   forward each time a key is pressed
  190.  
  191.   space           step one frame backwards
  192.  
  193.   return          continue display
  194.  
  195.   escape          quit program
  196.  
  197.  
  198. 4. Technical information
  199. ========================
  200.  
  201. The player is a rather straightforward implementation of the MPEG spec
  202. [1]. The IDCT is based on the Chen-Wang 11 multiplication algorithm [2]
  203. which was coded in assembler but does not use tables for multiplication.
  204. Blocks with not more than two non-zero coefficients use a non-separated
  205. direct multiply-accumulate 2D-IDCT, which turned out to be faster than a
  206. 'fast' algorithm in this (quite common) case. Dithering is pretty
  207. standard. Main difference to the Berkeley decoder (except for the fewer
  208. number of supported algorithms) is the use of 256 instead of 128 colors,
  209. the (default) option to use a restricted color-space and the
  210. implementation of a color saturation dominant ordered dither. This leads
  211. to a somewhat superior quality of the dithered image.
  212.  
  213. Restricted color-space means that the U and V components are clipped to
  214. +/-0.25 (instead of +/-0.5) and the display color-space points are
  215. distributed over this restricted space. Since the distance between
  216. color-space points is thus reduced by a factor of two, the color
  217. resolution is doubled at the expense of not being able to represent
  218. fully saturated colors.
  219.  
  220. Saturation dominant ordered dither is a method by which a color, lying
  221. somewhere between the points of the display color-space, is approximated
  222. by primarily alternating between two points of constant hue instead of
  223. constant saturation. This yields subjectivly better quality due to the
  224. lower sensitivity of the human viewing system to saturation changes than
  225. to hue changes (the same reasoning as used by the PAL TV standard to
  226. improve on NTSC). The improvement is particularly visible in dark brown
  227. or redish areas.
  228.  
  229.  
  230. 5. File formats
  231. ===============
  232.  
  233. If you want to write your own player or to post-process the results,
  234. here is the format of the 8 bit raw file:
  235.  
  236. Byte
  237.  
  238. 0..7      compatibility bytes (to be ignored)
  239. 8..9      image width  (MSB first)
  240. 10..11    image height (MSB first)
  241. 12..31    compatibility / unused
  242. 32..799   color table, R[0],G[0],B[0],  ... R[255],G[255],B[255]
  243. 800..     image data in natural order (top left to bottom right,
  244.           all frames concatenated without any gaps or repeated
  245.           headers)
  246.  
  247. The format of 24bit true color files (-d4 option) is:
  248.  
  249. 0..7      compatibility bytes (to be ignored)
  250. 8..9      image width  (MSB first)
  251. 10..11    image height (MSB first)
  252. 12..31    compatibility / unused
  253. 32..      image data (3 bytes per pixel: B,G,R, top left to bottom
  254.           right, all frames concatenated without any gaps or repeated
  255.           headers)
  256.  
  257. The 8 bit format happens to be compatible with the raw format used by a
  258. shareware program called Image Alchemy. In fact you can use that program
  259. to view the first frame of the sequence and to convert it into other
  260. formats.
  261.  
  262.  
  263. 6. Changes
  264. ==========
  265.  
  266. This is a list of major changes relative to version 1.0.
  267.  
  268. - speed improved by a factor of two through recoding of the IDCT and
  269.   interframe prediction routines in assembler and optimization of the
  270.   dithering algorithms
  271.  
  272. - support of TrueColor VGAs with VESA BIOS (only tested with Cirrus
  273.   Logic)
  274.  
  275. - DMPEG and DMPLAY merged into one program
  276.  
  277. - SVGA / TrueColor support for immediate display during decoding
  278.  
  279. - increased robustness against errors in the file to be decoded:
  280.   program tries to resynchronize on the next slice/frame header
  281.   instead of terminating
  282.  
  283. - format of the 24 bit raw file changed (B,G,R instead of R,G,B)
  284.  
  285.  
  286. 7. References
  287. =============
  288.  
  289. 1. Coding of moving pictures and associated audio for digital storage
  290.    media up to about 1,5 Mbit/s, Draft International Standard ISO/IEC
  291.    DIS 11172, 1992.
  292.  
  293. 2. Chen, Wang, IEEE ASSP-32, pp. 803-816, Aug. 1984.
  294.  
  295.  
  296. Appendix A: Related Software
  297. ============================
  298.  
  299. This list is probably incomplete, but it's all I'm aware of. Of course
  300. there are programs for other systems as well (Mac, Amiga etc.).
  301.  
  302. cmpeg          an MPEG encoder for the PC (DOS, 640K, no '386 req.)
  303.                for Targa, PBMPLUS and Alchemy RAW images
  304.                Author: myself
  305.  
  306. mpeg_play      MPEG Video Software Decoder (Version 2.0; Jan 27, 1993)
  307.                Authors: Lawrence A. Rowe, Ketan Patel, and Brian Smith
  308.                Computer Science Division-EECS, Univ. of Calif. at
  309.                Berkeley
  310.                toe.cs.berkeley.edu:/pub/multimedia/mpeg/mpeg-2.0.tar.Z
  311.  
  312. mpgplay        Online port of mpeg_play for DOS
  313.                by: Giampero Caprino, scompx@milano.oas.olivetti.com
  314.                (evaluation version, works only with Xing files)
  315. mpeg386.exe    Offline port of mpeg_play for DOS
  316.                by: Greg Ennis, 93gke@cs.williams.edu
  317.                (based on mpgplay, works only with Xing files)
  318. mpegwin        Online port of mpeg_play for MS-Windows
  319.                by: Michael Simmons, msimmons@ecel.uwa.edu.au
  320.                toe.cs.berkeley.edu:/pub/multimedia/mpeg/Ports/mpegw*
  321.                (HiColor & TrueColor support, Shareware)
  322.  
  323. mplay.exe,
  324. mpeg.exe       DOS MPEG players from Xing Technologies
  325.                (very high speed, but decodes only a small subset of the
  326.                 MPEG standard)
  327.  
  328. MPEGv1.1/1.2alpha
  329.                MPEG Software Encoder/Decoder
  330.                Authors: Portable Video Research Group (PVRG)
  331.                havefun.stanford.edu:/pub/mpeg/MPEGv*.tar.Z
  332.  
  333. mpgcodec       PVRG encoder/decoder for PC compiled with GNU gcc
  334.                ('386 required)
  335.                posted in alt.binaries.pictures.utilities
  336.  
  337.  
  338. APPENDIX B: MPEG files
  339. ======================
  340.  
  341. Two good sources for MPEG files:
  342.  
  343.   toe.cs.berkeley.edu:/pub/multimedia/mpeg/movies
  344.   havefun.stanford.edu:/pub/mpeg
  345.  
  346. High quality MPEGs you simply can't afford to miss:
  347.  
  348.   tennis.mpg
  349.   flowg.mpg
  350.   bike.mpg
  351.  
  352. --
  353. Stefan Eckart, stefan@lis.e-technik.tu-muenchen.de, June 1993.
  354.